<?php
session_start();
echo header('P3P: CP=CAO PSA OUR');
include_once( 'config.php' );
include_once( 'saetv2.ex.class.php' );
include_once( 'class.cjcx.php' );
include_once( 'class.db.php' );
include_once( 'func.php');
include_once( 'view.php');


//从POST过来的signed_request中提取oauth2信息
if(!empty($_REQUEST["signed_request"])){
	$o = new SaeTOAuthV2( WB_AKEY , WB_SKEY  );
	$data=$o->parseSignedRequest($_REQUEST["signed_request"]);
	if($data=='-2'){
		 die('签名错误!');
	}else{
		$_SESSION['oauth2']=$data;
	}
}
//判断用户是否授权
if (empty($_SESSION['oauth2']["user_id"])) {
		include "auth.php";
		exit;
} else {
		$c = new SaeTClientV2( WB_AKEY , WB_SKEY ,$_SESSION['oauth2']['oauth_token'] ,'' );
} 

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>教务辅助星</title>
<style>
html,body,div,h1,h2,h3,h4,h5,h6,h7,p,span,ul,li,img,form,a,table,tr,td{margin:0;padding:0;border:0;}
a{text-decoration:none; color:black;}
a:hover{color:red;}
ul,li{list-style:none;}
body{background-color:#70E1FF;}
h2{padding-bottom:10px; border-bottom:2px dashed #999; color:#0078B6;}
#page{width:760px; margin:auto auto; background-color:#70E1FF;}
#menu{float:left;}
#menu li{float:left; margin:10px 20px;}
#author{float:right; margin-right:50px;}
#author img{margin-right:10px; border-radius:5px;}
#board,#left,#right{background-color:white; border-radius:7px; padding:10px; font-family:'微软雅黑',sans-serif;}
#board{margin:20px; position:relative; width:700px;  height:51px; _padding:10px 0;}
#board a{font-size:20px;}
#left{float:left; width:330px; min-height:340px; margin-left:20px; _margin-left:10px;}
#right{float:left; margin-left:20px; width:330px; min-height:340px;text-align:center;}
#right p{margin:20px 0; font-size:24px; line-heigth:32px;}
#right input{height:30px; width:180px; line-height:30px; font-size:16px; color:#666666; background-color:white;}
#yourgrade{margin:20px;}
#gradelist{background-color:white; border-radius:7px; width:720px; font-size:14px; text-align:center;}
#gradelist td{padding:5px 0;}
#wbcontent{width:310px; height:180px; color:#444; font-size:16px; font-family:'楷体','黑体',sans-serif; line-height:125%;}
p.q{}
p.a{margin:0.5em 0 0 1em; color:#555; font-size:0.9em; line-height:150%;}
#about{background-color:white; border-radius:7px; margin:20px; padding:10px 20px; font-family:'微软雅黑',sans-serif;}
</style>
<script src="jquery.min.js" language="JavaScript"></script>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-26332099-2']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<script type="text/javascript" src="./jquery.min.js"></script>
<script>
$(document).ready(function(){
	$('#gradelist tr:odd').css('backgroundColor','#DEE9E9');
	$('#gradelist tr:even').css('backgroundColor','#ECECEC');
	$('#gradelist tr:first').css('backgroundColor','#B7B7B7');
	$('#jwuser').focus();
	$('input').each(function(){
		$(this).click(function(){
			$(this).trigger('select');
		})
	})
})
</script>
</head>
<script src="http://tjs.sjs.sinajs.cn/t35/apps/opent/js/frames/client.js" language="JavaScript"></script>

<body>
<div id="page">
<?php
	include('header.php');
	//echo "<pre>";
	//print_r($_SESSION);
	if($_POST['wbcontent']){
		$res = $c->update($_POST['wbcontent']);
		if($res) redirect($_GET['page'],"转发成功，感谢您的支持！");
		else redirect($_GET['page'],"无法注册微博信息！");
	}
	
	
	$jwuser = $_POST['jwuser'];
	$jwpass = $_POST['jwpass'];
	$sinaid = $_SESSION['oauth2']['user_id'];
	switch($_GET['page']){
		case 'push':	view_scan($sinaid,$jwuser,$jwpass,$_POST['email']);
						break;
		case 'pk':		view_evaluate($sinaid,$jwuser,$jwpass,$_POST['email']);
						break;
		case 'about':	view_about($c);
						break;
		default:		view_index($sinaid,$jwuser,$jwpass);
	}
	
	//include('footer.php')
?>
</div>
</body>
</html>
